/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: happyiu
 * Date: 2021-10-27
 * Time: 0:49
 */
public class TestDemo {

    public static void main1(String[] args) {
        String str = "result = ";
        int a = 10;
        int b = 20;
        String result = str + a + b;
        System.out.println(result);

    }

        public static void main2(String[] args) {
            int maxValue = 100;
            String studentName = "张三";
        }

    public static void main3(String[] args) {
        final int a = 10;
        //a = 20; // 编译出错. 提示 无法为最终变量a分配值
    }

    public static void main4(String[] args) {
        int a = 10;
        long b = 20;
        //a = b; // 编译出错, 提示可能会损失精度.
        b = a; // 编译通过.
    }

    public static void main5(String[] args) {
        int a = 10;
        double b = 1.0;
        //a = b; // 编译出错, 提示可能会损失精度.
        b = a; // 编译通过.
    }


   /* public static void main(String[] args) {
        int a = 10;
        boolean b = true;
        b = a; // 编译出错, 提示不兼容的类型
        a = b; // 编译出错, 提示不兼容的类型
    }*/

    /*public static void main(String[] args) {
        byte a = 100; // 编译通过
        byte b = 256; // 编译报错, 提示 从int转换到byte可能会有损失
    }*/

    public static void main6(String[] args) {
        int a = 0;
        double b = 10.5;
        a = (int)b;
        System.out.println(a);
    }

    public static void main7(String[] args) {
        int a = 9;
        int b = 5;
        System.out.println(a % b);
        System.out.println(11.5 % 2.0);


    }

    public static void main8(String[] args) {
        int a = 10;
        int b = 5;
        int c = 2;
        a += 1; // 等价于 a = a + 1
        System.out.println(a);
        b -= 2;// 等价于 b = b - 2
        System.out.println(b);
        c *= 5;// 等价于 c = c * 5
        System.out.println(c);
        //结果: 11 3 10
    }

    public static void main9(String[] args) {
        int a = 10;
        int b = 20;
        int c = ++a;
        System.out.println("a:"+a+" c:"+c);
        int d = b++;
        System.out.println("b:"+b+" d:"+d);
        //a:11 c:11
        //b:21 d:20
    }

    public static void main10(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(a == b);//false
        System.out.println(a != b);//true
        System.out.println(a < b);//true
        System.out.println(a > b); //false
        System.out.println(a <= b);//true
        System.out.println(a >= b);//false


    }

    public static void main11(String[] args) {
        int a = 10;
        int b = 20;
        int c = 30;
        System.out.println(a > b || b > c);
    }

    public static void main12(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(!(a < b));
    }

    public static void main13(String[] args) {
        System.out.println(10 > 20 && 10 / 0 == 0); // 打印 false
        System.out.println(10 < 20 || 10 / 0 == 0); // 打印 true
    }

    public static void main14(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(a | b);
    }

    public static void main15(String[] args) {
        int a = 0xf;
        System.out.printf("%x\n", ~a);
    }

    public static void main16(String[] args) {
        int a = 5;
        int b = 3;
        System.out.printf("%d\n", a ^ b);
    }

    public static void main(String[] args) {
        // 求两个整数的最大值
        int a = 10;
        int b = 20;
        int max = a > b ? a : b;
        //这里表示的就是a大于b吗，大于返回a，小于返回b
    }
}
